package com.payment.ktb.activity.main1;

import android.graphics.BitmapFactory;
import android.os.Bundle;
import android.os.Environment;
import android.text.TextUtils;
import android.view.View;
import android.widget.ImageView;
import android.widget.TextView;

import com.payment.ktb.R;
import com.payment.ktb.activity.BaseActivity;
import com.payment.ktb.constants.ConstantsUser;
import com.payment.ktb.utils.SharedPreferencesUtils;
import com.payment.ktb.utils.StringUtils;
import com.squareup.picasso.Picasso;

import java.io.File;

import butterknife.BindView;
import butterknife.ButterKnife;

/**
 * Created by syd on 2016/9/14.
 */
public class KKCardActivity extends BaseActivity {

    File file = new File(Environment.getExternalStorageDirectory(), SharedPreferencesUtils.getString(ConstantsUser.phone) + "avatar.png");

    @BindView(R.id.iv_kkcard_qr)
    ImageView iv_kkcard_qr;
    @BindView(R.id.iv_kkcard_qr_head)
    ImageView iv_kkcard_qr_head;
    @BindView(R.id.tv_kkcard_name)
    TextView tv_kkcard_name;
    @BindView(R.id.tv_kkcard_phone)
    TextView tv_kkcard_phone;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);

        setContentView(R.layout.activity_kkcard);
        ButterKnife.bind(this);
        initTitle("KK码");

        initViews();



    }

    private void initViews() {


        tv_kkcard_name.setText(getIntent().getStringExtra("shopAccount"));
        tv_kkcard_phone.setText(StringUtils.handelPhone(SharedPreferencesUtils.getString(ConstantsUser.phone)));

        if (!TextUtils.isEmpty(getIntent().getStringExtra("pic5"))) {
            Picasso.with(mContext).load(getIntent().getStringExtra("pic5")).fit().into(iv_kkcard_qr);
        }
        if (file != null && file.exists()) {
            iv_kkcard_qr_head.setImageBitmap(BitmapFactory.decodeFile(file.getPath()));
        } else {
            iv_kkcard_qr_head.setVisibility(View.GONE);
        }
    }
}
